<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="navbar.jsp" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>My JSP 'new_task.jsp' starting page</title>
    <link>
	<link rel="stylesheet" type="text/css" href="styles/css/bootstrap.min.css" />
	<link rel="stylesheet" href="styles/datepicker/css/datepicker.css" />
  </head>
  
  <body class="body">
    <div class="container" style="margin-top:60px;width:960px;margin-left:auto;margin-right:auto;">
	  <div class="row">
		<div class="span9">
		<form class="form-horizontal" action="goal.jspx?m=addTask" method="post" id="myform">

        <fieldset>&nbsp; 
          <legend>添加新任务</legend>
          <div class="control-group">
            <label class="control-label" for="input01">任务名称</label>
            <div class="controls">
              <input style="height:28px;" type="text" name="taskName" class="span5" id="taskName" x-webkit-speech="undefined"><br />
			  <span id="span1" style="color:red;"></span>
              <p class="help-block" style="color:green;">请添加您的任务名称…………</p>

            </div>
          </div>
          <div class="control-group">
            <label class="control-label" for="input01">开始时间</label>
            <div class="controls">
                  <div class="input-append date" id="dp3" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
				   		<input style="height:28px;" class="span2 datepicker" size="16" type="text" value="12-02-2012" name="startTime" id="startTime" ><br />
					    <span id="span2" style="color:red;"></span>
				  </div>
         	 </div>
		  </div>
          <div class="control-group">
            <label class="control-label" for="input01">截止时间</label>
            <div class="controls">
            
            	    <div class="input-append date" id="dp3" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
				   		<input style="height:28px;" class="span2 datepicker" size="16" type="text" value="12-02-2012" name="endTime" id="endTime"><br />
					    <span id="span3" style="color:red;"></span>
				    </div>
             
            </div>
          </div>
          <div class="control-group">
            <label class="control-label" for="input01">任务描述</label>

            <div class="controls">
              <textarea class="span5" rows="8" name="desc" id="desc"></textarea><br />
			  <span id="span4" style="color:red;"></span>
            </div>
          </div>
          <div class="control-group">
            <label class="control-label" for="multiSelect" >状态</label>
            <div class="controls">
              <select id="multiSelect" name="state">

                <option>新任务</option>
                <option>进行中</option>
                <option>已完成</option>
              </select>
            </div>
          </div>
          <div class="control-group">

            <label class="control-label" for="multiSelect">级别</label>
            <div class="controls">
              <select id="multiSelect" name="level">
                <option>重要紧急</option>
                <option>重要不紧急</option>
                <option>紧急不重要</option>
                <option>不紧急不重要</option>

              </select>
            </div>
          </div>
          <div class="control-group">
            <label class="control-label" for="multiSelect">负责人</label>
            <div class="controls">
            
      
              <select id="multiSelect" name="manager">
              
              	<c:forEach items="${requestScope.userList}" var="u">
            		<option value="${u.userId }">${u.userName }</option>
            	</c:forEach>
               
              </select>
            </div>
          </div>
          
          <input type="hidden" value="${requestScope.goalId }" name="goalId" />
          
          <div class="form-actions">
            <button type="button" class="btn btn-primary" id="btnSubmit">保存</button>

            <button class="btn" href="goal.jspx?m=new">返回</button>
          </div>
        </fieldset>
      </form>          
          	
		</div>
		<div class="span3">
			
		</div>
	  </div>
	</div>
	
	
	
	
	<script type="text/javascript" src="styles/jquery/jquery.js"></script>
	<script type="text/javascript" src="styles/datepicker/js/bootstrap-datepicker.js"></script>
	
	<script type="text/javascript">
	
		$(document).ready(function(){
			$("#btnSubmit").click(function(){
			
			//验证任务名称
				var taskName = $("#taskName").val();			
				if(taskName.trim().length == 0){			//在验证表单时是不能用看是不是=null来判断的，因为提交到表单之后肯定是空，而不是null，名字不可以是空格
					$("#span1").html("任务名称不能为空！");
					$("#taskName").focus();
					return ;
				} 
				if(taskName.trim().length > 20){
					$("#span1").html("姓名最多不超过20位！");
					$("#taskName").focus();
					return;
				}
				
		
				
				
					
			//验证简介
				var desc = $("#desc").val();			
				if(desc.trim().length == 0){			
					$("#span4").html("任务描述不能为空！");
					$("#desc").focus();
					return ;
				} 
				if(desc.trim().length > 300){
					$("#span4").html("任务描述最多不超过300位！");
					$("desc").focus();
					return;
				}
						
				
				$("#myform").submit();
			});
			
			$(".datepicker").datepicker();
		});
	</script>
  </body>
</html>
